home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / pc_board / callid1.zip / CALLERID.PPS < prev    next >
Text File  |  1993-04-06  |  5KB  |  163 lines

  1. ; *****************************************************************
  2. ; *                                                               *
  3. ; *                       CALLERID V 1 . 0                        *
  4. ; *                                                               *
  5. ; *                    Written in PPL for PCBoard                 *
  6. ; *                                                               *
  7. ; *                    Designed By:  Gary Meeker                  *
  8. ; *                                                               *
  9. ; *                    Began development: 04-06-93                *
  10. ; *                                                               *
  11. ; *****************************************************************
  12. ;
  13. ; This .PPE checks the secrity level of a user and if within the specified
  14. ; range, checks the Caller ID info for the phone number. If a number is
  15. ; found, then it writes it to the file specified.
  16. ;
  17. ; Usage:
  18. ;
  19. ; !Verify.PPE SecLow;SecHigh;IDType;CIDFile;PrivateFile;OutsideFile;NoMatchFile
  20. ;
  21. ; Where:
  22. ;      SecLow is the lowest level to display the file to
  23. ;     SecHigh is the highest level to display the file to
  24. ;      IDType is the type of Caller ID info or Position of the PhoneNumber+11
  25. ;             Predefined formats are 1-10
  26. ;             1 = Supra - scan for "NMBR = "           6
  27. ;             2                                        7
  28. ;             3                                        8
  29. ;             4                                        9
  30. ;             5                                       10
  31. ;     CIDFile is the caller ID file to create
  32. ; PrivateFile is the file to be displayed if the ID indicates Private
  33. ; OutsideFile is the file to be displayed if the ID indicates Outside Area
  34. ; NoMatchFile is the file to be displayed if the ID does not match Users Record
  35. ;
  36.  
  37. STRING CID, CIDFile, PrivateFile, NoMatchFile, OutSideFile
  38. STRING Private, Outside, Digits
  39. STRING HVPHONE, BDPHONE, PhoneNumber, Filter
  40. INTEGER SecLow, SecHigh, IDType, Pos, OffSet, X
  41.  
  42. ;Assume a "P" indicates a PRIVATE number and "O" indicates a OUTSIDE AREA number
  43.  
  44. Private = "P"
  45. Outside = "O"
  46.  
  47. ;Characters to Filter out of Users Record Phone Numbers
  48.  
  49. Filter = " -()+"
  50.  
  51. ;Parse the command line
  52.  
  53. GETTOKEN SecLow
  54. GETTOKEN SecHigh
  55. GETTOKEN IDType
  56. GETTOKEN CIDFile
  57. GETTOKEN PrivateFile
  58. GETTOKEN NoMatchFile
  59.  
  60. ;Delete any existing CIDFile first if one was specified
  61.  
  62. IF (CIDFile<>"") THEN
  63.    IF (EXIST(CIDFile)) THEN
  64.       DELETE CIDFile
  65.    END IF
  66. END IF
  67.  
  68. ;Get the Caller ID string and the Users info so we can get to U_SEC and such
  69.  
  70. CID = CALLID()
  71. GETUSER
  72.  
  73. ;Bail out if not within the desiredSecurity range or no Caller ID info
  74.  
  75. IF (U_Sec < SecLow | U_Sec > SecHigh | CID = "") STOP
  76.  
  77. ;Get HVPhone number and strip out other characters.
  78.  
  79. IF (NoMatchFile<>"") THEN
  80.    HVPHONE = U_HVPHONE
  81.    FOR X = 1 TO LEN(Filter)
  82.       HVPHONE = STRIP(HVPHONE,MID(Filter,X,1))
  83.    NEXT X
  84.    IF (LEFT(HVPHONE,1)="1") THEN
  85.       HVPHONE=MID(HVPHONE,2,LEN(HVPHONE)-1)
  86.    END IF
  87.    IF (HVPHONE="") LET HVPHONE="0000000000"
  88.  
  89.    ;Get BDPhone number and strip out other characters.
  90.  
  91.    BDPHONE = U_BDPHONE
  92.    FOR X = 1 TO LEN(Filter)
  93.       BDPHONE=STRIP(BDPHONE,MID(Filter,X,1))
  94.    NEXT X
  95.    IF (LEFT(BDPHONE,1)="1") THEN
  96.       BDPHONE=MID(BDPHONE,2,LEN(BDPHONE)-1)
  97.    END IF
  98.    IF (BDPHONE="") LET BDPHONE="00000000000"
  99. END IF
  100.  
  101. ;Find the postion of the Phone Number in the Caller ID string
  102.  
  103. IF (IDType = 1) THEN
  104.    Pos = INSTR(CID,"NMBR = ")
  105.    Offset = 7
  106. ;  Private = "P"
  107. ;  Outside = "O"
  108. ELSEIF (IDType > 11) THEN
  109.    Pos = IDType
  110.    Offset = -11
  111. ELSE
  112.    PRINTLN "I don't know that IDType (";IDType;")"
  113.    STOP
  114. END IF
  115.  
  116. ;Bail out if we didn't find it
  117.  
  118. IF (Pos = 0) STOP
  119.  
  120. ;Pull out just the Phone Number
  121.  
  122. PhoneNumber = UPPER(TRIM(MID(CID,Pos+Offset,10)," "))
  123.  
  124. ;If it's PRIVATE then show the file if specified
  125.  
  126. IF (LEFT(PhoneNumber,1)=Private & PrivateFile<>"") THEN
  127.    IF (EXIST(PrivateFile)) THEN
  128.       DISPFILE PrivateFile, LANG+SEC+GRAPH
  129.    END IF
  130.  
  131. ;If it's OUTSIDE AREA then show the file if specified
  132.  
  133. ELSEIF (LEFT(PhoneNumber,1)=Outside & OutsideFile<>"") THEN
  134.    IF (EXIST(OutsideFile)) THEN
  135.       DISPFILE OutsideFile, LANG+SEC+GRAPH
  136.    END IF
  137.  
  138. ;If it's not Home/Voice or Business/Data then show the file if specified
  139.  
  140. ELSEIF (NoMatchFile<>"" & RIGHT(PhoneNumber,LEN(HVPHONE))<>HVPHONE & RIGHT(PhoneNumber,LEN(BDPHONE))<>BDPHONE) THEN
  141.    IF (EXIST(NoMatchFile)) THEN
  142.       DISPFILE NoMatchFile, LANG+SEC+GRAPH
  143.    END IF
  144. END IF
  145.  
  146. ;Verify all digits and a full 10 of them at that
  147.  
  148. Digits = "1234567890"
  149. IF (LEN(PhoneNumber) < 10) STOP
  150. FOR Pos = 1 TO 10
  151.    IF (INSTR(Digits, MID(PhoneNumber,Pos,1))=0) STOP
  152. NEXT Pos
  153.  
  154. ;Write the number as AAA-EEE-NNNN to the desired file if specifed
  155.  
  156. IF (CIDFile<>"") THEN
  157.    FOPEN 1,CIDFile,O_WR,S_DB
  158.       FPUTLN 1,LEFT(PhoneNumber,3),"-",MID(PhoneNumber,4,3),"-",RIGHT(PhoneNumber,4)
  159.    FCLOSE 1
  160. END IF
  161.  
  162. END
  163.